;
(function() {
  new Vue({
    el: '#notice',
    data: {
      flag: true,
      orders: '#',
      columns: '#',
      pagetotal: 0,
      page: 1,
      limit: ['10'],
      pageCounts: [{name: '10', code: '10'}, {name: '15', code: '15'}, {name: '20', code: '20'}],
      modulesList: [],
      typeStatus: '',
      keyword: '',
      user: '',
      moduleId: '#',
      data: [],
      quanxian: JSON.parse(window.localStorage.getItem('permissions')),
      module_code: [],
      copyInputText: '',
    },
    filters: {
      framtTime(time) {
        return hlDateUtil.formatDate(time, 'yyyy-MM-dd HH:mm:ss')
      },
      formatDate: function(time) {
        if (time === undefined) return '--'
        return hlDateUtil.formatUTCDate(time, 'yyyy-MM-dd')
      },
    },
    methods: {
      //显示隐藏查询条件
      showHideTerm() {
        this.flag = !this.flag;
      },
      // 设置背景色
      addbgcolor(index) {
        let el = document.querySelectorAll('.house-two-tone');
        let el0 = document.querySelectorAll('.house-operate')
        el[index].classList.add('house-two-tone-hover')
        el0[index].classList.add('house-two-tone-hover')
      },
      //删除背景色
      removebgcolor(index) {
        let el = document.querySelectorAll('.house-two-tone');
        let el0 = document.querySelectorAll('.house-operate')
        el[index].classList.remove('house-two-tone-hover')
        el0[index].classList.remove('house-two-tone-hover')
      },
      //最后更新时间
      updateTime() {
        setTimeout(() => {
          this.getListData()
        }, 300)
        if (this.columns != 'UT') {
          this.columns = 'UT';
          this.orders = 'A';
          return
        }
        if (this.orders == 'A') {
          this.orders = 'D'
          return
        }
        if (this.orders == 'D') {
          this.orders = 'A'
          return
        }
      },
      //创建时间
      createTime() {
        setTimeout(() => {
          this.getListData()
        }, 300)
        if (this.columns != 'CT') {
          this.columns = 'CT';
          this.orders = 'A';
          return
        }
        if (this.orders == 'A') {
          this.orders = 'D'
          return
        }
        if (this.orders == 'D') {
          this.orders = 'A'
          return
        }
      },
      //新建/编辑负责人
      header_create_edit(type, id) {
        if (type == 'add') {
          hlUrlUtil.goTo('jwkparkServiceCreateEdit', {
            ddtab: true,
            type: type
          }, true)
          return
        }
        hlUrlUtil.goTo('jwkparkServiceCreateEdit', {
          ddtab: true,
          type: type,
          id: id
        }, true)
      },
      //重置
      reset() {
        this.keyword = '';
        this.module_code = [];
        this.orders = 'ASC';
        this.columns = 'CT';
        this.page = 1;
        this.limit = ['10'];
        this.getListData()
      },
			 //展示数量
			eventPage(arr) {
			  this.limit = [arr[0].code]
			  this.getListData()
			},
      //查询
      search() {
        this.page = 1
        this.limit = ['10'];
        this.getListData();
      },
      // 获取园区服务类型
      getoption() {
        var that = this
        hlhttp.get({
          url: 'configure/dict',
          data: {
            module_code: 'CSTM_JWK',
            config_name: 'CSTM_JWK_PARK_SERVICE_TYPE'
          },
          success: function(data) {
            that.modulesList = hlArrayUtil.replaceData(data, [{key: 'dictName', rKey: 'name'}, {key: 'dictCode', rKey: 'code'}]);
            that.getListData()
          },
        })
      },
      //选择服务类型
      eventModule(arr) {
        this.module_code = [arr[0].code]
      },
      //获取园区服务列表
      getListData() {
        hlhttp.get({
          url: 'jwk/park_services',
          data: {
            'keyword': this.keyword || '#',
            'module_code': this.module_code.length ? this.module_code[0] : '#',
            "page": this.page,
            "page_count": this.limit[0],
            "order": this.orders,
            "column": this.columns
          },
          success: (data) => {
            data.services.forEach(item => {
              this.modulesList.some(single => {
                if (item.moduleCode == single.dictCode) {
                  item.codeName = single.dictName
                }
              })
            })
            this.data = data
            $("#page").initPage(data.totalPage, this.page, (n) => {
              if (this.page == n) {
                return
              }
              this.page = n;
              this.getListData();
            });
          }
        })
      },
      //删除
      delItem(id) {
        hllayer.confirm('确认要删除该服务吗?', () => {
          hlhttp.delete({
            url: 'jwk/park_service?park_service_id=' + id,
            data: {
              'park_service_id': id,
            },
            success: (data) => {
              this.getListData();
            }
          })
        })
      },
      // 停用
      disableItem(id, type) {
        let opt = ''
        if (type == 'Y') {
          opt = 'N'
        } else {
          opt = 'Y'
        }
        hlhttp.put({
          url: 'jwk/park_service/_valid',
          data: {
            'park_service_id': id,
            'opt': opt
          },
          success: (data) => {
            this.getListData();
          }
        })
      },
      // 复制URL
      copyText(item) {
        this.copyInputText = this.systemContent[index].showName
        var Url = document.getElementById("copyInput");
        Url.value = this.copyInputText
        Url.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        hl.toast('复制成功')
      },
      //预览
      previewInfo(id) {
        hlUrlUtil.goTo('jwkpreviewService', {
          ddtab: true,
          portalArticleId: id,
          clear: true
        }, true)
      },
      copyURL(item) {
        hlhttp.get({
          url: 'configure/copy_url',
          data: {
            function_cate: 'COPYURL_JWK_YQFW',
            params: item.id
          },
          async: false,
          success: (data) => {
            var Url = document.getElementById("copyInput");
            Url.value = data.copyUrl;
          }
        })

      },
      copyss() {
        var Url = document.getElementById("copyInput");
        Url.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        hl.toast('复制成功')
      }
    },
    created() {
      hlSelectUi()
    },
    mounted() {
      this.getoption()
    }
  })
}())
